<template>
  <view class="family-verify">
    <view class="content">
      <view class="header-section">
        <h2 class="main-title">"成为TA的健康守护者"</h2>
        <p class="sub-title">随时查看家人血糖安全</p>
      </view>

      <view class="verify-methods">
        <view class="method-section">
          <h3 class="method-title">方式一：扫码绑定</h3>
          <view class="qr-section">
            <view class="steps">
              <view class="step">
                <view class="step-num">1</view>
                <view class="step-text">请患者打开小程序点击【添加家属】</view>
              </view>
              <view class="step">
                <view class="step-num">2</view>
                <view class="step-text">将手机对准患者屏幕上二维码，点击下方或使用微信扫一扫</view>
              </view>
              <view class="step">
                <view class="step-num">3</view>
                <view class="step-text">请患者打开小程序点击【添加家属】</view>
              </view>
            </view>
            <view class="qr-illustration">
              <img src="https://www.ruilongan.com/profile/upload/2025/06/25/qrcode_20250625115727A048.png" alt="QR Code Illustration" class="qr-image">
            </view>
          </view>
          <view class="scan-button">
            <img src="https://www.ruilongan.com/profile/upload/2025/06/25/scan_20250625100112A042.png" alt="Scan Button" class="scan-circle">
          </view>
        </view>

        <view class="method-section sms-method">
          <h3 class="method-title">方式二：短信验证</h3>
          <view class="sms-steps">
            <view class="step">
              <view class="step-num">1</view>
              <view class="step-text">输入患者注册手机号</view>
            </view>
            <view class="step">
              <view class="step-num">2</view>
              <view class="step-text">点击获取验证码</view>
            </view>
            <view class="step">
              <view class="step-num">3</view>
              <view class="step-text">输入患者告诉您的6位验证码</view>
            </view>
          </view>

          <view class="form-section">
            <view class="input-group">
              <view class="input-wrapper">
                <span class="input-label">手机号码</span>
                <input type="tel" v-model="phone" placeholder="请输入患者手机号" class="phone-input">
              </view>
            </view>
            <view class="input-group code-group">
              <view class="input-wrapper">
                <input type="text" v-model="verificationCode" placeholder="输入验证码" class="code-input">
                <button class="get-code-btn" @click="getVerificationCode" :disabled="counting">
                  {{ counting ? `${countdown}s` : '获取验证码' }}
                </button>
              </view>
            </view>
          </view>
        </view>
      </view>

      <button class="submit-btn" @click="submitVerification">立即守护</button>
    </view>
  </view>
</template>

<script>
export default {
  name: 'FamilyVerify',
  data() {
    return {
      phone: '',
      verificationCode: '',
      counting: false,
      countdown: 60
    }
  },
  methods: {
    getVerificationCode() {
      // 开始倒计时
      this.counting = true;
      this.countdown = 60;
      const timer = setInterval(() => {
        if (this.countdown > 0) {
          this.countdown--;
        } else {
          this.counting = false;
          clearInterval(timer);
        }
      }, 1000);
      
      // 获取验证码逻辑
    },
    submitVerification() {
      // 提交验证逻辑
    }
  }
}
</script>

<style scoped>
.family-verify {
  min-height: 100vh;
  background: #fff;
  padding: 14px;
}

.content {
  padding: 24px 20px;
}

.header-section {
  text-align: left;
  margin-bottom: 40px;
}

.main-title {
  font-size: 20px;
  font-weight: 500;
  color: #000;
  margin-bottom: 12px;
}

.sub-title {
  font-size: 16px;
  color: #979797;
  margin: 0;
}

.verify-methods {
  margin-bottom: 40px;
}

.method-section {
  margin-bottom: 32px;
  background: #fff;
  border-radius: 12px;
}

.method-title {
  font-size: 14px;
  font-weight: 500;
  color: #000;
  margin-bottom: 24px;
  position: relative;
  padding-left: 12px;
}

.sms-steps {
    margin-bottom: 30px;
}


.method-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  background: #4CD080;
  border-radius: 2px;
}

.steps {
  margin-bottom: 0;
  flex: 3;
}

.step {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
}

.step:last-child {
  margin-bottom: 0;
}

.step-num {
  width: 18px;
  height: 18px;
  background: #4CAF50;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-right: 12px;
  margin-top: 2px;
}

.step-text {
  font-size: 12px;
  color: #000;
  line-height: 1.4;
  flex: 1;
}

.qr-section {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.qr-illustration {
  flex-shrink: 0;
}

.qr-image {
  width: 100px;
  height: 120px;
  border-radius: 8px;
}

.scan-button {
  display: flex;
  justify-content: center;
  margin: 32px 0 16px;
}

.scan-circle {
  width: 120px;
  height: 120px;
}

.form-section {
  padding: 0 12px;
}

.input-group {
  margin-bottom: 16px;
  position: relative;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #F5F5F5;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  height: 48px;
}

.input-label {
  color: #000;
  font-size: 14px;
  padding-left: 16px;
  white-space: nowrap;
}

.phone-input, .code-input {
  flex: 1;
  height: 100%;
  border: none;
  padding: 0 16px;
  font-size: 15px;
  background: transparent;
}

.phone-input {
  text-align: right;
}

.phone-input::placeholder {
  text-align: right;
  color: #979797;
}

.code-input::placeholder {
  text-align: left;
  color: #979797;
}

.phone-input:focus, .code-input:focus {
  outline: none;
}

.input-wrapper:focus-within {
  border-color: #4CD080;
  background: #fff;
}

.code-group {
  display: flex;
  align-items: center;
}

.get-code-btn {
  position: relative;
  padding: 0 16px;
  height: 100%;
  background: none;
  border: none;
  border-left: 1px solid #E0E0E0;
  color: #4CD080;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.get-code-btn:disabled {
  color: #979797;
  cursor: not-allowed;
}

.submit-btn {
  width: 90%;
  height: 42px;
  background: #4CD080;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  margin-top: 40px;
}

.submit-btn:active {
  background: #43A047;
  transform: translateY(1px);
}

/* 暗色模式适配 */
@media (prefers-color-scheme: dark) {
  .family-verify {
    background: #121212;
  }
  
  .main-title, .method-title {
    color: #fff;
  }
  
  .sub-title, .step-text {
    color: rgba(255, 255, 255, 0.7);
  }
  
  .phone-input, .code-input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
  }
  
  .phone-input:focus, .code-input:focus {
    background: rgba(255, 255, 255, 0.1);
  }
}
</style>